package mypack.srverlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FontServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String word = request.getParameter("word");
		if (word == null) {
			word = "hello";
		}
		String color = this.getInitParameter("color");
		String size = this.getInitParameter("size");
		System.out.println("servlet name ===" + getServletName());
		ServletContext context = getServletContext();
		System.out.println("servlet path ==="+context.getContextPath());
		response.setContentType("text/html;charset=GB2312");
		PrintWriter pw = response.getWriter();
		pw.write("<html><head><title>FontServlet</title><head>");
		pw.write("<body>");
		pw.write("<font size='"+size+"' color='"+color+"' >"+word+"</font>");
		pw.write("<font size='"+size+"' color='"+color+"' >"+context.getInitParameter("test")+"</font>");
		pw.write("</body></html>");
		pw.close();
		
	}

}
